package com.wsc.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.wsc.entity.Section;
import com.wsc.service.SectionService;

@RequestMapping("/section")
@RestController
@CrossOrigin
public class SectionController {
	@Autowired
	private SectionService ss;
	//增
	@RequestMapping("add")
	public Integer add(Section s) {
		return ss.add(s);
	}
	//删除
	@RequestMapping("delete")
	public Integer delete(Integer id) {
		return ss.delete(id);
	}
	//改
	@RequestMapping("update")
	public Integer update(Section s) {
		return ss.update(s);
	}

	// id name remark
	@RequestMapping("getAll")
	public Map<String, Object> getAll(String name, Integer page, Integer limit) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("name", name);
		limit = limit == null ? 10 : limit;
		page = page == null ? 0 : page - 1;
		params.put("limit", limit);
		params.put("page", page);
		return ss.getAll(params);

	}

}
